<div class="pageHeader">
    <form onsubmit="return navTabSearch(this);" action="<?php echo site_url('c=pipeline&m=index');?>" method="post">
        <div class="searchBar">

            <select class="combox" name="pipe_name">
                <?php foreach ($pipe_list as $pipe) { ?>
                    <option <?php if ($pipe['pipe_name'] == $pipe_name) { ?> selected="selected" <?php } ?>
                        value="<?php echo $pipe['pipe_name']; ?>"> <?php echo $pipe['pipe_title'];?></option>
                <?php } ?>
            </select>

            <div class="subBar">
                <ul>
                    <li>
                        <div class="buttonActive">
                            <div class="buttonContent">
                                <button type="submit">确定</button>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </form>
</div>

<table layoutH="170" class="table" width="100%">
    <thead>
    <tr>
        <th width="10"></th>
        <th width="15">订单号</th>
        <th width="25">权重</th>
        <th width="100">下单时间</th>
        <th width="100">订单留言</th>
        <th width="25">订单地址</th>
        <th width="25">买家姓名</th>
        <th width="20">买家电话</th>
        <th width="20">订单类型</th>
        <th width="20">派送时间</th>
        <th width="100">品名</th>
        <th width="50">规格</th>
        <th width="20">数量</th>
        <th width="20">单位</th>
        <th width="100">操作</th>
    </tr>
    </thead>
    <tbody>
    <?php foreach ($pipedb['list'] as $k => $pipe) { ?>
        <tr>
            <td rowspan="<?php echo sizeof($pipe['info']); ?>"><?php echo ($k + 1) ?></td>
            <td rowspan="<?php echo sizeof($pipe['info']); ?>"><?php echo $pipe['work_code'] ?></td>
            <td rowspan="<?php echo sizeof($pipe['info']); ?>"><?php echo $pipe['work_weight'] ?></td>
            <td rowspan="<?php echo sizeof($pipe['info']); ?>"><?php echo date('Y-m-d H:i:s', $pipe['order_time']); ?></td>
            <td rowspan="<?php echo sizeof($pipe['info']); ?>"><?php echo $pipe['order_message'] ?></td>
            <td rowspan="<?php echo sizeof($pipe['info']); ?>"><?php echo $pipe['order_addr'] ?></td>
            <td rowspan="<?php echo sizeof($pipe['info']); ?>"><?php echo $pipe['buyer_name'] ?></td>
            <td rowspan="<?php echo sizeof($pipe['info']); ?>"><?php echo $pipe['phone'] ?></td>
            <td rowspan="<?php echo sizeof($pipe['info']); ?>"><?php echo $pipe['market'] ?></td>
            <td rowspan="<?php echo sizeof($pipe['info']); ?>"><?php echo $pipe['send_time_point'] ?></td>
            <?php $info = current($pipe['info'])?>
            <td><?php echo '1.' . $info['wi_title'] ?></td>
            <td><?php echo $info['wi_spec'] ?></td>
            <td><?php echo $info['wi_num'] ?></td>
            <td><?php echo $info['wi_unit'] ?></td>
            <td rowspan="<?php echo sizeof($pipe['info']); ?>">
                <?php foreach ($pipe_list as $pipe_node) { ?>
                    <?php if ($pipe_node['pipe_name'] != $pipe_name) { ?>
                        <a href="javascript:adjust_pipe('<?php echo $pipe['work_code']; ?>','<?php echo $pipe_name; ?>','<?php echo  $pipe_node['pipe_name']; ?>');">
                            调整到<?php echo $pipe_node['pipe_title']; ?>
                        </a>
                    <?php
                    }
                } ?>
            </td>
        </tr>
        <?php if (sizeof($pipe['info']) > 1) {
            foreach ($pipe['info'] as $k => $info) {
                if ($k == 0) continue;
                ?>
                <tr>
                    <td><?php echo ($k + 1) . '.' . $info['wi_title'] ?></td>
                    <td><?php echo $info['wi_spec'] ?></td>
                    <td><?php echo $info['wi_num'] ?></td>
                    <td><?php echo $info['wi_unit'] ?></td>
                </tr>
            <?php
            }
        } ?>
    <?php } ?>

    </tbody>
</table>
<script type=" text/javascript">
    function adjust_pipe(work_code, from, to) {
        $.post('<?php echo site_url('c=pipeline&m=adjust_pipe&');?>' + parseInt(10 * Math.random()),
            {'work_code': work_code, 'from': from, 'to':to}, function (data) {
                navTab.reload("<?php echo site_url('c=pipeline&m=index&');?>pipe_name=" + from + "&" + parseInt(10 * Math.random()), "", "pipeline_index");
            });
    }
</script>
